package com.biodiv.community.enums;

import com.biodiv.community.base.EnumBase;

/**
 * @author tianquan
 */

public enum PostTypeEnum implements EnumBase {

    PUBLIC_POST("public_post", "公开帖子"),

    SYSTEM_NOTICE("system_notice", "系统公告"),

    COMMUNITY_PRIVATE_POST("community_private_post", "社区私有帖子"),

    COMMUNITY_PUBLIC_POST("community_public_post", "社区公开帖子"),

    COMMUNITY_NOTICE("community_notice", "社区公告");

    private final String type;
    private final String desc;

    PostTypeEnum(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static boolean isValid(String type) {
        for (PostTypeEnum value : values()) {
            if (value.name().equals(type)) {
                return true;
            }
        }
        return false;
    }

    public static boolean equals(PostTypeEnum postType, String type) {
        return type.equals(postType.getType());
    }

    public static PostTypeEnum getEnum(String type) {
        for (PostTypeEnum value : values()) {
            if (value.name().equals(type)) {
                return value;
            }
        }
        throw new IllegalArgumentException("无效的帖子类型！");
    }

    @Override
    public String getType() {
        return type;
    }

    @Override
    public String getDesc() {
        return desc;
    }

}